package com.block.test.factory;

import com.block.common.enums.ApiReqEnum;
import com.block.common.util.ApplicationContextUtil;
import com.block.test.service.IReqRecordService;
import com.block.test.service.record.ProdListRecordService;
import com.block.test.service.record.SysCountRecordService;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求记录
 *
 */
public class ReqRecordFactory {
    private static Map<String, Class<? extends IReqRecordService>> serviceMap = new HashMap<>(30);

    static {
        serviceMap.put(ApiReqEnum.PROD_UV.getValue(), SysCountRecordService.class);
        serviceMap.put(ApiReqEnum.PROD_LIST.getValue(), ProdListRecordService.class);
    }

    /**
     * 根据uri获取实现类
     *
     * @param uri
     * @return
     */
    public static IReqRecordService getService(String uri) {
        Class<? extends IReqRecordService> validataService = serviceMap.get(uri);
        if (validataService != null) {
            return ApplicationContextUtil.getBean(validataService);
        }
        return null;
    }
}
